<?php
	class CompanyModel extends CI_Model
	{
		public function __construct()
		{
			$this->load->database();
		}
		public final function addCompany($company)
		{
			$b = $company;
			$a = array
			(
				'Name' => $b->Name,
				'Type' => $b->Type,
				'Website' => $b->Website,
				'Landline' => $b->Landline,
				'Mobile' => $b->Mobile,
				'Fax' => $b->Fax,
				'Email' => $b->Email,
				'Address' => $b->Address
			);
			$this->db->insert('companies', $a);
		}
		public final function getAllCompanies()
		{
			$q = $this->db->get('companies');
			return $q->result_object();
		}
		public final function getCompanyById($id)
		{
			$q = $this->db->get_where('companies', array('Id' => $id));
			return $q->result_object();
		}
		public final function updateCompany($company)
		{
			$b = $company;
			$a = array
			(
				'Name' => $b->Name,
				'Type' => $b->Type,
				'Website' => $b->Website,
				'Landline' => $b->Landline,
				'Mobile' => $b->Mobile,
				'Fax' => $b->Fax,
				'Email' => $b->Email,
				'Address' => $b->Address
			);
			$this->db->where('Id', $b->Id);
			$this->db->update('companies', $a);
		}
		public final function removeCompanyById($id)
		{
			$q = $this->db->delete('companies', array('Id', $id));
			return $q->result_object();
		}
	}